package makovo.ajax;

import java.io.IOException;
import java.io.Serializable;
import java.sql.SQLException;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import makovo.data.Resources;
import makovo.entities.SysUser;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;

public class UserInfo extends ActionSupport implements Serializable, ServletRequestAware, SessionAware {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private HttpServletRequest mRequest;
	private String user;
	private SysUser infoUser;
	private Map<String, Object> mSession;

	public String getUser() {
		return this.user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public SysUser getInfoUser(){
		return infoUser;
	}
	
	public String getUserInfo() {
		this.user = "Pánfilo Celerino";

		return ActionSupport.SUCCESS;
	}

	public String getUserGeoInfo() {
		try {
			infoUser = Resources.getUserByMail((String) mSession.get("login.email"));
			
			return ActionSupport.SUCCESS;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ActionSupport.ERROR;
	}

	@Override
	public void setServletRequest(HttpServletRequest request) {
		this.mRequest = request;
	}

	@Override
	public void setSession(Map<String, Object> session) {
		this.mSession = session;
	}

}
